import { Input } from 'antd';
import { FC } from 'react';
import { IParameterar } from '../../types';
import $http from '../../axios'
import { API } from '../../axios'
import { AxiosResponse } from 'axios';
const { Search } = Input;

interface IProps {
    updateLists(lists: IParameterar): void,
    pageSize?: number
}

const Select: FC<IProps> = ({
    updateLists,
    pageSize
}) => {

    const inputChange = async (e: any) => {
        const fileName: string = e.target.value;
        if (fileName.trim() === "") {
            pageSize = 10;
        }
        const { data }: AxiosResponse<IParameterar> = await $http.get(API + `?pageNo=1&pageSize=${pageSize}&filename=${fileName}`)
        // 更新文件列表
        updateLists(data)

    }

    return (

        <div className="right">
            <Search placeholder="请输入文件名称" onChange={inputChange} style={{ width: 200 }} />
        </div>

    )
}

export default Select
